#include <errno.h>

#include <linux/sched.h>
#include <linux/tty.h>
#include <linux/kernel.h>
#include <asm/segment.h>
#include <sys/times.h>
#include <sys/utsname.h>
#include <string.h>


#define SYS_STRLEN	23
static char myname[SYS_STRLEN+1] = {0};

int sys_iam(const char * name)
{
	char *b =name;
	unsigned int i = 0;
	while(1)	{
		myname[i] = get_fs_byte(b++);
		if(myname[i] == '\0'){
			break;
		}

		i++;
		if( i> SYS_STRLEN){
			myname[0] = '\0';
			//printk("kernel:name len %u more than 23\n", i+1);
			return -EINVAL;
		}
	}
	
	//printk("kernel: save name %s\n", myname);
	return i;
	
}

int sys_whoami(char* name, unsigned int size)
{
	unsigned int i = 0;
	unsigned int len = strlen(myname);
	char *b =name;
	if(len>=size){
		//printk("kernel: name len %u more than buffer %u\n", len, size);
		return -EINVAL;
	}

	while(1)	{
		put_fs_byte(myname[i], b++);
		if(myname[i] == '\0'){
			break;
		}

		i++;
	}
	//printk("kernel: output name %s\n", myname);
	return len;
}
